package android.slc.module.system.repository.service

import android.slc.adapter.PageModel
import android.slc.appbase.api.slc.callback.po.SlcEntity
import android.slc.appbase.api.slc.config.ApiConfig
import android.slc.or.SlcNu
import android.slc.or.SlcParam
import android.slc.rx.SlcRxJavaUtils
import android.slc.sys.entity.SystemNotify
import android.slc.sys.entity.SystemNotifySpecific
import android.slc.sys.repository.service.SystemNotifyService
import io.reactivex.rxjava3.core.Observable

object SystemNotifyRepository {
    /**
     * 获取系统通知
     */
    fun notificationList(
        offset: Int,
        status: Int
    ): Observable<SlcEntity<PageModel<SystemNotify>>> {
        return SlcNu.getInstance().create(SystemNotifyService::class.java).notificationList(
            SlcParam.newBuilder()
                .put("size", ApiConfig.getInstance().pageSize)
                .put("current", offset)
                .put("status", status)
                .build()
        ).compose(SlcRxJavaUtils.applyOoAndroidSchedulers())
    }

    /**
     * 获取系统通知
     */
    fun notificationDetail(
        id: String
    ): Observable<SlcEntity<List<SystemNotifySpecific>>> {
        return SlcNu.getInstance().create(SystemNotifyService::class.java).notificationDetail(id)
            .compose(SlcRxJavaUtils.applyOoAndroidSchedulers())
    }

    /**
     * 个人中心消息个数
     */
    fun messagesNumber(): Observable<SlcEntity<Int>> {
        return SlcNu.getInstance().create(SystemNotifyService::class.java).messagesNumber()
            .compose(SlcRxJavaUtils.applyOoAndroidSchedulers())
    }
}